Add ‘ing’ at the end¶
Add ‘ing’ at the end of a given string (length should be at least 3).
If the given string already ends with ‘ing’ then add ‘ly’ instead.
If the string length of the given string is less than 3,
leave it unchanged.
Sample String :
‘abc’
Expected Result :
‘abcing’
Sample String :
‘string’
Expected Result :
‘stringly’
def add_string(S):
str_length = len(S)
if str_length > 2:
if S[-3:] == 'ing':
S += 'ly'
else:
S += 'ing'
return S
# test
print(add_string('ab')) # ab
print(add_string('abc')) # abcing
print(add_string('string')) # stringly